<?php

namespace app\admin\controller;

use app\common\controller\AdminController;

//引入外部函数
use app\common\model\hfztcy\LibCollect;


/**
 * 收藏记录
 * @name CollectRecord.php
 * @package hfztcy
 * @category controller
 * @author rxy
 * @version 1.0
 * @copyright CHANGE INC
 * @since 2020-6-5
 */
class CollectRecord extends AdminController
{
    protected $model;

    /**
     * 构造函数
     */
    public function __construct()
    {
        $this->model = new LibCollect();
        $this->rightVerify(session('admin'), url("admin/Login/login"));
        parent::__construct();
    }

    /**
     * 列表页
     */
    function collectList()
    {
        $this->getSetMenu($this);
        $this->log(__CLASS__, __FUNCTION__, "列表页", 1, 'view');
        return $this->fetch('CollectRecord/collectRecordList/collectRecordList');
    }

    /**
     * 分页查询
     */
    function pagingCollect()
    {
        $args = $this->getArgsList($this, ['user_id', 'username','state','is_fans']);
        $page = $this->getPageInfo();
        $where = [];
        if (!empty($args['state'])) {
            if ($args['state'] != 5) {
                $where[] = "FIND_IN_SET({$args['state']},identity)";
            } else {
                $where[] = "(`a`.`is_vip_video_z` > 0 or `a`.`is_red_mother_video_z` > 0)";
            }
        }
        if (!empty($args['username'])) $where[] = "`username` = '" . $args['username'] . "'";
        if ($args['is_fans'] == '1') {
            if (!empty($args['user_id'])) $where[] = "`like_user_id` = " . $args['user_id'];
        } else {
            if (!empty($args['user_id'])) $where[] = "`user_id` = " . $args['user_id'];
        }
        $result = $this->model->pagingCollect($page, implode(' AND ', $where));
        echo json_encode($result);
    }
}

?>